<?php
//session_start();
include "general_include.php";

/* Deatils of Coach */
$page_name=basename($_SERVER['SCRIPT_FILENAME']);
$IsPreserved = 'Y';
$IsProcess = $_REQUEST['IsProcess'];
$action	= $_REQUEST['action'];
$coach_id = $_REQUEST['coach_id'];
$game_id = $_REQUEST['game_id']; 
$logged_user=$_SESSION['user_id'];


if($_REQUEST['action']=='sendreview')
{
	
	$num_coach_rating_type=$_REQUEST['NumCoachRatingCat'];
	//$coach_id = $_POST['coach_id'];
	$user_type_id=$_POST['user_type_id'];
	$review_comment = $_POST['review_comment'];
	$reviewed_by=$_POST['reviewed_by'];
	$total_rating=0;
	
	for($i=0;$i<$num_coach_rating_type;$i++){
		
		$get_rating[$i]=$_REQUEST['Rating_'.$i.''];
		$get_comment[$i]=$_REQUEST['Comment_'.$i.''];
		$explode_str=explode(":",$get_rating[$i]);
		$rating[$i]=$explode_str[0];
		$rating_cat_id[$i]=$explode_str[1];
		$store_id[$i]=$_REQUEST['comment_rating_'.$i.''];
	}
	
	$overall_comment=$_REQUEST['Comment_overall'];
	$overall_rating=$_REQUEST['Rating_overall'];
	
	$CoachReviewSql="INSERT INTO ".TABLEPREFIX."_user_review 
					(
					user_id,
					user_type_id,
					reviewed_by,
					review_comment,
					rating,
					is_active,
					date_added
					)
					VALUES
					(
					'".$coach_id."',
					'".$user_type_id."',
					'".$reviewed_by."',
					'".$review_comment."',
					'".$overall_rating."',
					'Y',
					'".date('Y-m-d')."'
					)";
	$CoachReview=$UserManagerObjAjax->Execute($CoachReviewSql);
	$user_review_id=mysql_insert_id();
	
	if($num_coach_rating_type>0){
	
		for($i=0;$i<$num_coach_rating_type;$i++){
		
			$total_rating=$total_rating+$rating[$i];
			
				$CoachRatingSql="INSERT INTO ".TABLEPREFIX."_user_rating
								 (
								 user_review_id,
								 rcat_id,
								 rating
								 )
								 VALUES
								 (
								 '".$user_review_id."',
								 '".$rating_cat_id[$i]."',
								 '".$rating[$i]."'
								 )";
				$CoachRating=$UserManagerObjAjax->Execute($CoachRatingSql);
	
		}
		
		if($CoachRating){
			$totreview = "SELECT count(*),sum(rating) as totrate FROM ".TABLEPREFIX."_user_review WHERE user_id='".$coach_id."' AND is_active='Y'";
            $totArr = $UserManagerObjAjax->GetRecords("Row",$totreview);
		    $tot_count = $totArr[0];
            $tot_rate = $totArr['totrate'];
		    $avg = $tot_rate/$tot_count;
			
	        $UpdateSql = "UPDATE ".TABLEPREFIX."_user_type_user_relation SET overall_rating='".$avg."' WHERE user_id='".$coach_id."' and user_type_id='".$user_type_id."'";
	        $UserManagerObjAjax->Execute($UpdateSql);
		}
	}


}



if($IsProcess <> 'Y')
{
	include "top.php";
	
}

$RatingCatSql="SELECT rating_category_tooltip,rating_category,rcat_id FROM ".TABLEPREFIX."_rating_category WHERE rating_type='C' ORDER BY rating_order";
$RatingCatDetails=$UserManagerObjAjax->GetRecords("All",$RatingCatSql);

$NumRatingCat=count($RatingCatDetails);

for($i=0;$i<$NumRatingCat;$i++){
	
	$RatingCatArr[$i]['rcat_id']=$RatingCatDetails[$i]['rcat_id'];
	$RatingCatArr[$i]['rating_category']=$RatingCatDetails[$i]['rating_category'];
	$RatingCatArr[$i]['rating_category_tooltip']=$RatingCatDetails[$i]['rating_category_tooltip'];
}

$Sql_Individual="select avg(rat.rating) as tot,rat.rcat_id,cat.rating_category,cat.rating_category_tooltip from ".TABLEPREFIX."_user_rating as rat,".TABLEPREFIX."_user_review as rev,".TABLEPREFIX."_rating_category as cat where rat.rcat_id=cat.rcat_id and rat.user_review_id=rev.user_review_id and rev.user_id=".$coach_id." and rev.user_type_id=1 group by rat.rcat_id";
$Individual=$UserManagerObjAjax->GetRecords("All",$Sql_Individual);

for($j=0;$j<count($Individual);$j++){

	$CatIndividualRec[$j]['rating']=number_format($Individual[$j]['tot'], 1, '.', '');
	$CatIndividualRec[$j]['rcat_id']=$Individual[$j]['rcat_id'];
	$CatIndividualRec[$j]['rating_category']=$Individual[$j]['rating_category'];
	$CatIndividualRec[$j]['rating_category_tooltip']=html_entity_decode($Individual[$j]['rating_category_tooltip']);
}

/*echo '<pre>';
print_r($CatIndividualRec);*/

$item_per_page=$_SESSION['item_per_page'] = $_REQUEST['item_per_page'];

	if(empty($item_per_page) || !isset($item_per_page))
	{
	$item_per_page=10;
	} 


  //Start fetching game criteria of a particular game ---------------------//
	$GameSql = "SELECT * FROM ".TABLEPREFIX."_game WHERE game_id='$game_id'";  
	$gamerow = $UserManagerObjAjax->GetRecords("Row",$GameSql);
	$game_id = $gamerow['game_id'];
	$game_name = $gamerow['game_name'];
	$is_ladder = $gamerow['is_ladder'];
	$is_race = $gamerow['is_race'];
	$is_server = $gamerow['is_server'];
	$is_region = $gamerow['is_region'];
	$is_rating = $gamerow['is_rating'];
  //End fetching game criteria  --------------------------------------------//

 // Search values for left panel
    
	$ladder_id = explode(" , ",$_REQUEST['ladders']);   // Explode Code Added By Chandan
	$server_id = explode(" , ",$_REQUEST['servers']);
	$race_id = explode(" , ",$_REQUEST['races']);
	$region_id = explode(" , ",$_REQUEST['regions']);
	$rating_id = explode(" , ",$_REQUEST['ratings']);
	$availability = explode(" , ",$_REQUEST['availabilitys']);
	$language_id = explode(" , ",$_REQUEST['languages']);
	$price = $_REQUEST['price'];

	if($ladder_id == '')
	   $ladder_id =array(0);
	if($race_id == '')
	   $race_id =array();
	if($server_id == '')
	   $server_id =array();
	if($region_id == '')
	   $region_id =array();
	if($rating_id == '')
	   $rating_id =array();
	if($availability == '')
	   $availability = array();   
	if($language_id == '')
	  $language_id = array();
	if($price == '')
	  $price = '0;100';
  // --------------------------------------------------------------------------//

 // Start Favourite coach selection by student
	if($action == 'make_fav')
	{
	  $coach_id=$_REQUEST['coach_id'];
	  $add_fav = "INSERT INTO ".TABLEPREFIX."_user_fav_coach SET user_id='".$_SESSION['user_id']."',coach_id='$coach_id',date_added='".date('Y-m-d')."'";
	  $UserManagerObjAjax->Execute($add_fav);
	}
	if($action == "del_fav")
    {	
	  $fav_coach_id=$_REQUEST['fav_coach_id'];
	  $DelSql = "DELETE FROM ".TABLEPREFIX."_user_fav_coach where fav_coach_id='$fav_coach_id'";
	  $UserManagerObjAjax->Execute($DelSql);
   }  
 // End  Favourite coach selection by student

 // Function for finding value 
	function findvalue($table,$fld_name,$fld_value,$find_value)
	{
		 if($fld_value=='')
				return false;
				
			$SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
			$SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
			return $SelectType[0];
	}	
//Review Submit 

/*if(isset($_POST['submit']))
{
    $review_comment = $_POST['review_comment'];
	$rating = $_POST['rating'];
	$coach_id = $_POST['coach_id'];
	$Sql = "INSERT INTO ".TABLEPREFIX."_user_review set reviewed_by='".$_SESSION['user_id']."',user_id='$coach_id',user_type_id='1',review_comment='$review_comment',
	rating='$rating',date_added='".date('Y-m-d')."'";
	$UserManagerObjAjax->Execute($Sql);
	

}
*/

$CoachSql="SELECT * FROM ".TABLEPREFIX."_user where user_id='$coach_id'";
$CoachArr=$UserManagerObjAjax->GetRecords("Row",$CoachSql);

$CoachArr['name']=show_to_control($CoachArr['name']);
$CoachArr['about']=stripslashes($CoachArr['user_about']);
$CoachArr['desc']=stripslashes($CoachArr['description']);


$Clanguage = explode(",",$CoachArr['language_ids']);
	$language='';
	for($l=0;$l<count($Clanguage);$l++)
	{
	   if($Clanguage[$l]<>'')
	    $language .=findvalue(TABLEPREFIX."_language","language_id",$Clanguage[$l],"language_name").' , ';
	}
$CoachArr['language']=substr($language,0,-2);   

$avail_type = explode(",",$CoachArr['availability_type']);
if($avail_type[1] == '')
{
  if($avail_type[0]=='O')
   $CoachArr['availability_type'] = 'Online';
  if($avail_type[0]=='L')
  { 
   $CoachArr['availability_type'] = 'Local meet-up';
   $CoachArr['avail_local'] = 'Y';
  } 
}
else
{
  $CoachArr['availability_type'] = 'Online , Local meet-up';  
  $CoachArr['avail_local'] = 'Y';
}  

$CoachArr['availability_country'] = findvalue(TABLEPREFIX."_country","country_id",$CoachArr['availability_country'],"country_name");
$CoachArr['availability_city'] = findvalue(TABLEPREFIX."_cities","city_id",$CoachArr['availability_city'],"city_key");

$CoachOverall="SELECT overall_rating FROM ".TABLEPREFIX."_user_type_user_relation WHERE user_id=".$coach_id." and user_type_id=1";
$CoachOverallArr = $UserManagerObjAjax->GetRecords("Row",$CoachOverall);
$CoachOverallArr['overall_rating']=number_format($CoachOverallArr['overall_rating'], 1, '.', '');

$Sql_overall_tooptip="select rating_overall_tooltip from ".TABLEPREFIX."_default_comision";
$overall_tooptip=$UserManagerObjAjax->GetRecords("Row",$Sql_overall_tooptip);
$CoachOverallArr['rating_overall_tooltip']=html_entity_decode($overall_tooptip['rating_overall_tooltip']);



$CoachgameSql = "SELECT * FROM ".TABLEPREFIX."_user_game where user_id='$coach_id' and user_type_id=1 and is_active='Y'";
$CoachgameArr = $UserManagerObjAjax->GetRecords("All",$CoachgameSql);
$Numcoachgame=count($CoachgameArr);
for($g=0;$g<$Numcoachgame;$g++)
{
    $gameSql = "SELECT * FROM ".TABLEPREFIX."_game WHERE game_id ='".$CoachgameArr[$g]['game_id']."'";
	$gameRow =  $UserManagerObjAjax->GetRecords("Row",$gameSql);
	
    $CoachgameArr[$g]['is_ladder'] = $gameRow['is_ladder'];
	$CoachgameArr[$g]['is_race'] = $gameRow['is_race'];
	$CoachgameArr[$g]['is_server'] = $gameRow['is_server'];
	$CoachgameArr[$g]['is_rating'] = $gameRow['is_rating'];
	$CoachgameArr[$g]['is_region'] = $gameRow['is_region'];
    $CoachgameArr[$g]['game']= findvalue(TABLEPREFIX."_game","game_id",$CoachgameArr[$g]['game_id'],"game_name");
	$CoachgameArr[$g]['ladder']= findvalue(TABLEPREFIX."_game_ladder","ladder_id",$CoachgameArr[$g]['ladder_id'],"ladder_name");
	$Coachrace = explode(",",$CoachgameArr[$g]['race_id']);
	$race='';
	for($i=0;$i<count($Coachrace);$i++)
	{
	  if($Coachrace[$i]<>'')
	    $race .= findvalue(TABLEPREFIX."_game_race","race_id",$Coachrace[$i],"race_title").' , ';
	} 
	$CoachgameArr[$g]['race']= substr($race,0,-2);
	$Coachserver = explode(",",$CoachgameArr[$g]['server_id']);
	$server='';
	for($i=0;$i<count($Coachserver);$i++)
	{
	  if($Coachserver[$i]<>'')
	    $server .= findvalue(TABLEPREFIX."_game_server","server_id",$Coachserver[$i],"server_name").' , ';
	} 
	$CoachgameArr[$g]['server']= substr($server,0,-2);
	$Coachregion = explode(",",$CoachgameArr[$g]['region_id']);
	$region='';
	for($i=0;$i<count($Coachregion);$i++)
	{
	  if($Coachregion[$i]<>'')
	   $region .= findvalue(TABLEPREFIX."_game_region","region_id",$Coachregion[$i],"region_title").' , ';
	} 
	$CoachgameArr[$g]['region']= substr($region,0,-2);
	
	$Coachrating = explode(",",$CoachgameArr[$g]['rating_id']);
	$rating='';
	for($i=0;$i<count($Coachrating);$i++)
	{
	  
	  if($Coachrating[$i]<>'')
	    $rating .= findvalue(TABLEPREFIX."_game_rating","rating_id",$Coachrating[$i],"rating_title").' , ';
	} 
	$CoachgameArr[$g]['rating']= substr($rating,0,-2);
}

$CoachvideoSql = "SELECT * FROM ".TABLEPREFIX."_video WHERE user_id='$coach_id' ORDER BY date_added DESC";
$CoachvideoArr =  $UserManagerObjAjax->GetRecords("All",$CoachvideoSql);
$Numvideo = count($CoachvideoArr);
for($v=0;$v<$Numvideo;$v++)
{
    /*$CoachvideoArr[$v]['game'] = findvalue(TABLEPREFIX."_game","game_id",$CoachvideoArr[$v]['game_id'],"game_name");
	$dateSql = "SELECT date_format('".$CoachvideoArr[$v]['date_added']."','%M  %d , %Y') as video_date";*/
	$DateArr = $UserManagerObjAjax->GetRecords("Row",$dateSql);
    $CoachvideoArr[$v]['video_date']=date("F j, Y",strtotime($CoachvideoArr[$v]['date_added'])).' at '.date("g:i a",strtotime($CoachvideoArr[$v]['date_added']));
	
	$LikeNumSql = "SELECT count(*) AS numlike FROM ".TABLEPREFIX."_user_like WHERE selected_for='L' AND video_id=".$CoachvideoArr[$v]['video_id'] ;
	$LikeArrNum = $UserManagerObjAjax->GetRecords('Row',$LikeNumSql);
	
	$CoachvideoArr[$v]['numlike']=$LikeArrNum['numlike'];
	
	$UnlikeNumSql = "SELECT count(*) AS numunlike FROM ".TABLEPREFIX."_user_like WHERE selected_for='D' AND  video_id=".$CoachvideoArr[$v]['video_id'] ;
	$UnlikeArrNum = $UserManagerObjAjax->GetRecords('Row',$UnlikeNumSql);
	
	$CoachvideoArr[$v]['numunlike']=$UnlikeArrNum['numunlike'];

	
	$totstar='';
		for($x=1;$x<=$CoachvideoArr[$v]['overall_rating'];$x++)
		{
		  $totstar.="<img src='images/starb.gif' alt='' border='0' />";
		}
		$istar=5 - $CoachvideoArr[$v]['overall_rating']; 
		for($y=1;$y<=$istar;$y++)
		{
		  $totstar.="<img src='images/starg.gif' alt='' border='0' />";
		}
		$CoachvideoArr[$v]['star']=$totstar;
		$viewCount = "SELECT count(*) FROM ".TABLEPREFIX."_video_view_count WHERE video_id =".$CoachvideoArr[$v]['video_id'];
		$viewArr = $UserManagerObjAjax->GetRecords("Row",$viewCount);
		$CoachvideoArr[$v]['view_count'] = $viewArr[0];
		
}


  // $review_by_cuser = "SELECT * FROM ".TABLEPREFIX."_user_review WHERE  reviewed_by='".$_SESSION['user_id']."' and user_id='$coach_id'";
  // $Arr = $UserManagerObjAjax->GetRecords("Row",$review_by_cuser);
  // $is_reviewed = count($Arr);

 $Reviews = "SELECT * FROM ".TABLEPREFIX."_user_review WHERE user_id='$coach_id' and user_type_id=1 and is_active='Y' ORDER BY date_added DESC";
 
 $PaginationObjAjaxLatest=new PaginationClassAjax($item_per_page,"prev",'',"next","active",$adodbcon);
 $pagination_arr = $PaginationObjAjaxLatest->PaginationAjax($Reviews,$page_name."?coach_id=".$coach_id."&action=".$action."&item_per_page=".$item_per_page,"Managergeneral");
 $UserReview = $UserManagerObjAjax->GetRecords("All",$pagination_arr[0]);
 
/* echo '<pre>';
 print_r($UserReview);*/
 
 $NumReview = count($UserReview);
 
 for($r=0;$r<$NumReview;$r++)
 {
    $UserReview[$r]['review_by'] = findvalue(TABLEPREFIX."_user","user_id",$UserReview[$r]['reviewed_by'],"name");
	
    /*$RdateSql = "SELECT date_format('".$UserReview[$r]['date_added']."','%M  %d , %Y') as review_date";
	$RdateArr = $UserManagerObjAjax->GetRecords("Row",$RdateSql);*/
	
	$UserReview[$r]['r_date']    = date("F j, Y",strtotime($UserReview[$r]['date_added'])).' at '.date("g:i a",strtotime($UserReview[$r]['date_added']));
	$UserReview[$r]['overall_c'] = $UserReview[$r]['overall_comment'];
	$UserReview[$r]['overall_r'] = $UserReview[$r]['rating'];
	
	$Sql_overall_tooptip="select rating_overall_tooltip from ".TABLEPREFIX."_default_comision";
	$overall_tooptip=$UserManagerObjAjax->GetRecords("Row",$Sql_overall_tooptip);
	$UserReview[$r]['rating_overall_tooltip']=html_entity_decode($overall_tooptip['rating_overall_tooltip']);

	
	//echo $Sql_Individual_User="select rat.rating,cat.rating_category from gt_user_rating as rat,gt_user_review as rev,gt_rating_category as cat where rat.rcat_id=cat.rcat_id and rat.user_review_id=rev.user_review_id and rev.user_review_id=".$UserReview[$r]['user_review_id']." and rev.reviewed_by=".$UserReview[$r]['reviewed_by']." group by cat.rating_category";
	$Sql_Individual_User="SELECT rat.rating, cat.rating_category, cat.rating_category_tooltip FROM ".TABLEPREFIX."_user_rating AS rat, ".TABLEPREFIX."_user_review AS rev, ".TABLEPREFIX."_rating_category AS cat WHERE rat.rcat_id = cat.rcat_id AND rat.user_review_id = rev.user_review_id AND rat.user_review_id =".$UserReview[$r]['user_review_id']." GROUP BY cat.rcat_id";
	$Individual_User =  $UserManagerObjAjax->GetRecords("All",$Sql_Individual_User);
	
	
	//$id=$UserReview[$r]['user_review_id'];
	for($k=0;$k<count($Individual_User);$k++){
	
	$UserReview_Individual[$k]['rating']=$Individual_User[$k]['rating'];
	$UserReview_Individual[$k]['rating_category']=$Individual_User[$k]['rating_category'];
	$UserReview_Individual[$k]['rating_category_tooltip']=html_entity_decode($Individual_User[$k]['rating_category_tooltip']);
	
	}
	$UserReview[$r]['individual'] = $UserReview_Individual; 
	//
	/*$tot_star='';
		for($x=1;$x<=$UserReview[$r]['rating'];$x++)
		{
		
		  $tot_star.="<img src='images/star-c.gif' alt='' border='0' />";
		}
		$istar=5 - $UserReview[$r]['rating']; 
		for($y=1;$y<=$istar;$y++)
		{
		  $tot_star.="<img src='images/star-g.gif' alt='' border='0' />";
		}
		$UserReview[$r]['rating']=$tot_star;*/
		
	$userImg = "SELECT photo FROM ".TABLEPREFIX."_user WHERE user_id='".$UserReview[$r]['reviewed_by']."'";
	$ImgArr = $UserManagerObjAjax->GetRecords("Row",$userImg);
	$UserReview[$r]['photo'] = $ImgArr[0];	
	
	$Usertype = "SELECT user_type_id FROM ".TABLEPREFIX."_user_type_user_relation WHERE user_id='".$UserReview[$r]['reviewed_by']."'";
	$typeArr = $UserManagerObjAjax->GetRecords("All",$Usertype);
	for($t=0;$t<count($typeArr);$t++)
	{
	  if($typeArr[$t][0] == 1)
	     $coach = 1;
	  if($typeArr[$t][0] == 3)
	     $partner = 1;	 
	}
	if($coach == 1)
	{ 
	   $UserReview[$r]['userlink'] = "coachdetails.php?coach_id=".$UserReview[$r]['reviewed_by'];
	  if($UserReview[$r]['photo'] == '')
	    $img = 'images/coach_thumb.jpg';
	  else
	  	$img = 'uploaded/user_images/thumbs/mid_'.$UserReview[$r]['photo'];
	}
	else if($partner == 1)
	{
	  $UserReview[$r]['userlink'] = "training_partner_details.php?training_partner_id=".$UserReview[$r]['reviewed_by']; 
	  if($UserReview[$r]['photo'] == '')
	    $img = 'images/student_thumb.jpg';
	  else
	  	$img = 'uploaded/user_images/thumbs/mid_'.$UserReview[$r]['photo'];
	}  
	else 
	{ 
	   $UserReview[$r]['userlink'] = '#';
	   if($UserReview[$r]['photo'] == '')
	    $img = 'images/student_thumb.jpg';
	  else
	  	$img = 'uploaded/user_images/thumbs/mid_'.$UserReview[$r]['photo'];
	}  
	
	
	  $UserReview[$r]['img'] = $img;
 }
//echo '<pre>';print_r($UserReview_Individual);exit;
// Selecting favourite coach
if($_SESSION['user_type'] == '2')
{
   $q_fav = "SELECT * FROM ".TABLEPREFIX."_user_fav_coach WHERE user_id='".$_SESSION['user_id']."' AND coach_id='$coach_id'";
   $FavArr = $UserManagerObjAjax->GetRecords("Row",$q_fav);
   if($FavArr['fav_coach_id'] >0)
     $is_fav = 1;
   else 
     $is_fav=0;	 
}
$city = findvalue(TABLEPREFIX."_cities","city_id",$availability_city,"city_key");


$gameSql = "SELECT game_id,game_name FROM ".TABLEPREFIX."_game where is_active='Y' ORDER BY game_name";
$GameArr = $UserManagerObjAjax->HtmlOptionArrayCreate($gameSql);

$friendsSql = "SELECT * FROM ".TABLEPREFIX."_user_friends_list WHERE (nk_user_id_owner='".$_SESSION['user_id']."' or nk_user_id_friend='".$_SESSION['user_id']."') and (nk_user_id_owner='".$coach_id."' or nk_user_id_friend='".$coach_id."')";
$friendsArr = $UserManagerObjAjax->GetRecords("All",$friendsSql);
$isfriend = "n";
for($t=0;$t<count($friendsArr);$t++){
	if($friendsArr[$t]['nk_user_id_friend'] == $coach_id || $friendsArr[$t]['nk_user_id_owner'] == $coach_id){
		$isfriend = "y";
		break;
	}
}
/*0-offline, 1-online, 2-away*/
/*
$online_status = 'offline';
if($CoachArr['is_logged_in'] == '1'){

	switch ($CoachArr['online_status']) {
		case "0":
			$online_status= 'offline';	
			break;
		case "1":
			$online_status = 'online';	
			break;
		case "2":
			$online_status = 'away';	
			break;
		case "3":
			$online_status = 'busy';	
			break;
	}
}	
*/
$online_status = getUserStatus($CoachArr);

$smarty->assign('online_status',$online_status);
$smarty->assign('isfriend',$isfriend);
$smarty->assign('price',$price);
$smarty->assign('ladder_id',$ladder_id);
$smarty->assign('race_id',$race_id);
$smarty->assign('server_id',$server_id);
$smarty->assign('region_id',$region_id);
$smarty->assign('rating_id',$rating_id);
$smarty->assign('language_id',$language_id);
$smarty->assign('availability',$availability);
$smarty->assign('city',$city);
$smarty->assign('cityid',$availability_city);
$smarty->assign('availability_country',$availability_country);
$smarty->assign('availability_city',$availability_city);
$smarty->assign('game_id',$game_id);
$smarty->assign("GameArr",$GameArr);
$smarty->assign('RatingCatArr',$RatingCatArr);
$smarty->assign('NumReview',$NumReview);
$smarty->assign('UserReview',$UserReview);
$smarty->assign('Numcoachgame',$Numcoachgame);
$smarty->assign('Numvideo',$Numvideo);
$smarty->assign('CoachvideoArr',$CoachvideoArr);
$smarty->assign('CoachgameArr',$CoachgameArr);
$smarty->assign('CoachArr',$CoachArr);
$smarty->assign('coach_id',$coach_id);
$smarty->assign('is_fav',$is_fav);
$smarty->assign('fav_id',$FavArr['fav_coach_id']);
$smarty->assign('IsProcess',$IsProcess);
$smarty->assign('pagination_arr',$pagination_arr);
$smarty->assign('page_name',$page_name);
$smarty->assign('NumRatingCat',$NumRatingCat);
$smarty->assign('RatingCatArr',$RatingCatArr);
$smarty->assign('logged_user',$logged_user);
$smarty->assign('CatIndividualRec',$CatIndividualRec);
$smarty->assign('UserReview_Individual',$UserReview_Individual);
$smarty->assign('CoachOverallArr',$CoachOverallArr);
$smarty->assign('ratingArr',$ratingArr);
if($IsProcess <> 'Y')
  include "coach_leftpanel.php";
$smarty->display('coachdetails.tpl');
if($IsProcess <> 'Y')
   include "footer.php";
?>